#ifndef GAMEKIT_uint_H
#define GAMEKIT_uint_H

#include <map>
#include <vector>

#include "gamekit.h"

#include "common/SafePointer.h"
#include "common/SharedPointer.h"
#include "common/AutoPointer.h"

#include "drawing/Canvas.h"

namespace gamekit
{
	class Game;
	class Window;
	class Component;

	EXPORT_STL_VECTOR(GK_API, Component*)
	EXPORT_STL_VECTOR(GK_API, SharedPointer<Canvas>)

	class GK_API Scene
	{
		friend class Game;
		friend class Component;

	private:
		SafePointer<Game> m_game;
		std::vector<Component*> m_components;
		std::vector<SharedPointer<Canvas> > m_canvasesCache;
		bool m_lockCanvasesCache;
	
	private:
		Scene(SafePointer<Game> game);
	
		void init(void);
		void update(const uint& elapsed);
		void draw(const uint& elapsed);
	
		void updateCanvasesCache(void);

	public:
		~Scene();

		template<typename T>
		SafePointer<T> createComponent();
	
		void beginUpdateCanvasesCache(void);
		void endUpdateCanvasesCache(void);

		SafePointer<Game> game(void) const;
		SafePointer<Window> window(void) const;
	};

	template<typename T>
	SafePointer<T> Scene::createComponent()
	{
		T* component = new T(this);
		m_components.push_back(component);

		return SafePointer<T>(component);
	}
}

#endif
